<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/11 0011
 * Time: 上午 10:34
 */

namespace App\Eloquent\Ygt;

use Framework\BaseClass\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Eloquent\Ygt\DbEloquent;
use DB;

class Plate extends DbEloquent
{
    use SoftDeletes;
    protected $table = 'ygt_plate';
    protected $dates = ['deleted_at'];
    protected $dateFormat = 'U';

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     * 客户的数据库关联
     */
    public function customer(){
        return $this->hasOne('App\Eloquent\Ygt\Customer','id','customer_id');
    }
    public function buyer(){
        return $this->hasOne('App\Eloquent\Ygt\Buyers','id','buyer_id');
    }

    /**
     * @param bool $categoryId
     * @return array|mixed
     * 获取版的分类
     */
    public static function getCategory($categoryId=false){
        $categorys = [
            1=>[
                'id'=>1,
                'title'=>'电雕版'
            ],
            2=>[
                'id'=>2,
                'title'=>'橡胶版'
            ],
            3=>[
                'id'=>3,
                'title'=>'PS版'
            ],
            4=>[
                'id'=>4,
                'title'=>'树脂版'
            ],
            5=>[
                'id'=>5,
                'title'=>'其他'
            ],
        ];

        return $categoryId?(isset($categorys[$categoryId])?$categorys[$categoryId]:false):$categorys;
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     * 支的数据库关联
     */
    public function branch(){
        return $this->hasMany('App\Eloquent\Ygt\Branch');

    }
}